<?php
declare(strict_types=1);

namespace App\Resource\Group\Party;


use App\Enums\GroupEnum;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class Resource extends JsonResource
{
    public function toArray($request)
    {
        if(empty($this->id)){
            return [];
        }
        return [
            "id" => $this->id,
            "category_id" => $this->category_id,
            "group_id" => $this->group_id,
            "city_id" => $this->city_id,
            "latitude" => $this->latitude,
            "longitude" => $this->longitude,
            "user_id" => $this->user_id,
            "type" => $this->allow_count == 2 ? 'CP派对' : '交友派对',
            "title" => $this->title,
            "content" => $this->content,
            "cover" => $this->cover,
            "count" => $this->count,
            "allow_count" => $this->allow_count,
            "reply_count" => count($this->reply),
            "gender" => $this->gender,
            "address" => $this->address,
            "owner" => UserResource::make($this->user),
            "members" => MemberResource::collection($this->members),
            "reply" => ReplyListResource::collection($this->reply),
            "is_free" => $this->is_free,
            "is_online" => $this->is_online,
            "status" => $this->status,
            // "show_status" => $status,
            "start_at" => $this->start_at,
            "end_at" => $this->end_at,
            "created_at" => $this->created_at->toDateTimestring(),
        ];
    }
}